<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>模型推理与监控 - AI 中心</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        .nav-pills .nav-link.active {
            background-color: #0d6efd;
        }
        .metric-card {
            transition: transform 0.2s;
        }
        .metric-card:hover {
            transform: translateY(-5px);
        }
        .prediction-chart {
            height: 400px;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="#">模型推理与监控</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="../index.html">返回 AI 中心</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container-fluid">
        <div class="row">
            <!-- 左侧导航 -->
            <div class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
                <div class="position-sticky pt-3">
                    <ul class="nav flex-column nav-pills">
                        <li class="nav-item">
                            <a class="nav-link active" href="#real-time-prediction" data-bs-toggle="pill">
                                <i class="bi bi-graph-up me-2"></i>实时预测
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#anomaly-detection" data-bs-toggle="pill">
                                <i class="bi bi-exclamation-triangle me-2"></i>异常检测
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#resource-monitoring" data-bs-toggle="pill">
                                <i class="bi bi-cpu me-2"></i>资源监控
                            </a>
                        </li>
                    </ul>
                </div>
            </div>

            <!-- 右侧内容 -->
            <div class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
                <div class="tab-content">
                    <!-- 实时预测 -->
                    <div class="tab-pane fade show active" id="real-time-prediction">
                        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                            <h1 class="h2">实时预测</h1>
                            <div>
                                <button class="btn btn-outline-primary me-2">
                                    <i class="bi bi-download"></i> 导出数据
                                </button>
                                <button class="btn btn-primary">
                                    <i class="bi bi-pause-fill"></i> 暂停
                                </button>
                            </div>
                        </div>

                        <div class="row">
                            <!-- 预测图表 -->
                            <div class="col-md-8">
                                <div class="card mb-4">
                                    <div class="card-body">
                                        <canvas id="predictionChart" class="prediction-chart"></canvas>
                                    </div>
                                </div>
                            </div>

                            <!-- 预测指标 -->
                            <div class="col-md-4">
                                <div class="row">
                                    <div class="col-md-12 mb-4">
                                        <div class="card metric-card">
                                            <div class="card-body text-center">
                                                <h6 class="card-title">当前预测值</h6>
                                                <h2 class="text-primary">25.6°C</h2>
                                                <small class="text-muted">置信度: 95.8%</small>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-12 mb-4">
                                        <div class="card metric-card">
                                            <div class="card-body text-center">
                                                <h6 class="card-title">预测趋势</h6>
                                                <h2 class="text-success">上升</h2>
                                                <small class="text-muted">较上次 +0.5°C</small>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <div class="card">
                                            <div class="card-header">
                                                <h5 class="card-title mb-0">最近预测</h5>
                                            </div>
                                            <div class="card-body">
                                                <div class="table-responsive">
                                                    <table class="table table-sm">
                                                        <thead>
                                                            <tr>
                                                                <th>时间</th>
                                                                <th>预测值</th>
                                                                <th>实际值</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <tr>
                                                                <td>15:30:00</td>
                                                                <td>25.6°C</td>
                                                                <td>25.8°C</td>
                                                            </tr>
                                                            <tr>
                                                                <td>15:29:00</td>
                                                                <td>25.1°C</td>
                                                                <td>25.3°C</td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 异常检测 -->
                    <div class="tab-pane fade" id="anomaly-detection">
                        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                            <h1 class="h2">异常检测</h1>
                            <button class="btn btn-primary">
                                <i class="bi bi-gear"></i> 配置规则
                            </button>
                        </div>

                        <div class="row">
                            <!-- 异常列表 -->
                            <div class="col-md-6">
                                <div class="card mb-4">
                                    <div class="card-header">
                                        <h5 class="card-title mb-0">异常记录</h5>
                                    </div>
                                    <div class="card-body">
                                        <div class="list-group">
                                            <a href="#" class="list-group-item list-group-item-action">
                                                <div class="d-flex w-100 justify-content-between">
                                                    <h6 class="mb-1">温度异常</h6>
                                                    <small class="text-danger">10分钟前</small>
                                                </div>
                                                <p class="mb-1">温度值超出正常范围 (25.6°C > 25.0°C)</p>
                                                <small>设备ID: DEV001</small>
                                            </a>
                                            <a href="#" class="list-group-item list-group-item-action">
                                                <div class="d-flex w-100 justify-content-between">
                                                    <h6 class="mb-1">振动异常</h6>
                                                    <small class="text-danger">30分钟前</small>
                                                </div>
                                                <p class="mb-1">振动值异常波动 (0.8 > 0.5)</p>
                                                <small>设备ID: DEV002</small>
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- 异常统计 -->
                            <div class="col-md-6">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title mb-0">异常统计</h5>
                                    </div>
                                    <div class="card-body">
                                        <canvas id="anomalyChart" height="300"></canvas>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 资源监控 -->
                    <div class="tab-pane fade" id="resource-monitoring">
                        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                            <h1 class="h2">资源监控</h1>
                            <button class="btn btn-primary">
                                <i class="bi bi-download"></i> 导出报告
                            </button>
                        </div>

                        <div class="row">
                            <!-- CPU使用率 -->
                            <div class="col-md-6 mb-4">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title mb-0">CPU使用率</h5>
                                    </div>
                                    <div class="card-body">
                                        <canvas id="cpuChart" height="200"></canvas>
                                    </div>
                                </div>
                            </div>

                            <!-- 内存使用率 -->
                            <div class="col-md-6 mb-4">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title mb-0">内存使用率</h5>
                                    </div>
                                    <div class="card-body">
                                        <canvas id="memoryChart" height="200"></canvas>
                                    </div>
                                </div>
                            </div>

                            <!-- 资源使用详情 -->
                            <div class="col-md-12">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title mb-0">资源使用详情</h5>
                                    </div>
                                    <div class="card-body">
                                        <div class="table-responsive">
                                            <table class="table">
                                                <thead>
                                                    <tr>
                                                        <th>资源类型</th>
                                                        <th>使用量</th>
                                                        <th>总量</th>
                                                        <th>使用率</th>
                                                        <th>状态</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr>
                                                        <td>CPU</td>
                                                        <td>2.5 核心</td>
                                                        <td>4 核心</td>
                                                        <td>
                                                            <div class="progress">
                                                                <div class="progress-bar" role="progressbar" style="width: 62.5%"></div>
                                                            </div>
                                                        </td>
                                                        <td><span class="badge bg-success">正常</span></td>
                                                    </tr>
                                                    <tr>
                                                        <td>内存</td>
                                                        <td>3.2 GB</td>
                                                        <td>8 GB</td>
                                                        <td>
                                                            <div class="progress">
                                                                <div class="progress-bar" role="progressbar" style="width: 40%"></div>
                                                            </div>
                                                        </td>
                                                        <td><span class="badge bg-success">正常</span></td>
                                                    </tr>
                                                    <tr>
                                                        <td>GPU</td>
                                                        <td>1.8 GB</td>
                                                        <td>4 GB</td>
                                                        <td>
                                                            <div class="progress">
                                                                <div class="progress-bar" role="progressbar" style="width: 45%"></div>
                                                            </div>
                                                        </td>
                                                        <td><span class="badge bg-success">正常</span></td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script>
        // 预测图表
        const predictionCtx = document.getElementById('predictionChart').getContext('2d');
        new Chart(predictionCtx, {
            type: 'line',
            data: {
                labels: ['15:25', '15:26', '15:27', '15:28', '15:29', '15:30'],
                datasets: [{
                    label: '实际值',
                    data: [24.8, 25.0, 25.2, 25.3, 25.5, 25.6],
                    borderColor: 'rgba(54, 162, 235, 1)',
                    tension: 0.4
                }, {
                    label: '预测值',
                    data: [24.9, 25.1, 25.2, 25.4, 25.5, 25.7],
                    borderColor: 'rgba(255, 99, 132, 1)',
                    borderDash: [5, 5],
                    tension: 0.4
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: false
                    }
                }
            }
        });

        // 异常统计图表
        const anomalyCtx = document.getElementById('anomalyChart').getContext('2d');
        new Chart(anomalyCtx, {
            type: 'bar',
            data: {
                labels: ['温度', '湿度', '压力', '振动'],
                datasets: [{
                    label: '异常次数',
                    data: [5, 3, 2, 4],
                    backgroundColor: [
                        'rgba(255, 99, 132, 0.5)',
                        'rgba(54, 162, 235, 0.5)',
                        'rgba(255, 206, 86, 0.5)',
                        'rgba(75, 192, 192, 0.5)'
                    ],
                    borderColor: [
                        'rgba(255, 99, 132, 1)',
                        'rgba(54, 162, 235, 1)',
                        'rgba(255, 206, 86, 1)',
                        'rgba(75, 192, 192, 1)'
                    ],
                    borderWidth: 1
                }]
            },
            options: {
                scales: {
                    y: {
                        beginAtZero: true
                    }
                }
            }
        });

        // CPU使用率图表
        const cpuCtx = document.getElementById('cpuChart').getContext('2d');
        new Chart(cpuCtx, {
            type: 'line',
            data: {
                labels: ['15:25', '15:26', '15:27', '15:28', '15:29', '15:30'],
                datasets: [{
                    label: 'CPU使用率',
                    data: [45, 50, 55, 60, 65, 62.5],
                    borderColor: 'rgba(54, 162, 235, 1)',
                    tension: 0.4,
                    fill: true,
                    backgroundColor: 'rgba(54, 162, 235, 0.1)'
                }]
            },
            options: {
                scales: {
                    y: {
                        beginAtZero: true,
                        max: 100
                    }
                }
            }
        });

        // 内存使用率图表
        const memoryCtx = document.getElementById('memoryChart').getContext('2d');
        new Chart(memoryCtx, {
            type: 'line',
            data: {
                labels: ['15:25', '15:26', '15:27', '15:28', '15:29', '15:30'],
                datasets: [{
                    label: '内存使用率',
                    data: [35, 37, 38, 39, 40, 40],
                    borderColor: 'rgba(75, 192, 192, 1)',
                    tension: 0.4,
                    fill: true,
                    backgroundColor: 'rgba(75, 192, 192, 0.1)'
                }]
            },
            options: {
                scales: {
                    y: {
                        beginAtZero: true,
                        max: 100
                    }
                }
            }
        });
    </script>
</body>
</html> 